package com.rabbit01.controller;

import com.rabbit01.config.ConfirmConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * //发送消息开始确认
 */
@Slf4j
@RestController
@RequestMapping("/confirm")
public class ProducerController {

    @Autowired
    private RabbitTemplate template;

    /**
     * 发送消息
     */
    @GetMapping("/sendMessage")
    public void sendMessage(String message){
        //
        CorrelationData correlationData = new CorrelationData("1");
        template.convertAndSend(
                ConfirmConfig.CONFIRM_EXCHANGE,"ConfirmConfig.CONFIRM_ROUTING_KEY",message,correlationData);

        log.info("发消息内容为：{}",message);
    }

}
